約 5,252,441 件
https://w.atwiki.jp/kylico/pages/49.html
?xml version="1.0" encoding="utf-8"? LinearLayout xmlns android="http //schemas.android.com/apk/res/android" android orientation="vertical" android layout_width="fill_parent" android layout_height="fill_parent" Button android text="Button"android id="@+id/button1"android layout_width="wrap_content"android layout_height="wrap_content"android onClick="onClickButton1" /Button /LinearLayout
https://w.atwiki.jp/android/pages/43.html
チュートリアル:ノートパッドエクササイズ1 本エクササイズではシンプルなノートリストを作ります。このノートリストを使ってユーザは新規ノートを追加することができますが、ノートの編集を行うことはできません。本エクササイズでは以下の事項をデモンストレートします。 ListActivities の基本、メニューオプションの作成・操作の基本 SQLite データベース内のノートへのアクセス/保存方法 ArrayAdapter (ListView にバインドするためのもっともシンプルな方法の一つ)を用いてデータを ListView にバインドする方法 リストビューの配置の仕方やアクティビティメニューへのアイテムの追加のやり方、アクティビティがアクティビティメニューアイテムをどのように扱うか、といったスクリーンレイアウトの基本 [エクササイズ1] [エクササイズ2?] [エクササイズ3?] [追加事項?] Step 1 Notepadv1 プロジェクトを開きます。 Notepadv1 は開始点として提供されるプロジェクトです - it takes care of some of the boilerplate work that you have already seen if you followed the Hello Android tutorial (すでにHello Android(もしもしアンドロイド)のチュートリアルで見ているかもしれませんが、共通する説明があります。) 2. browse ボタンを押し、あなたが本エクササイズをコピーしたフォルダを選択し、その中からNotepadv1を選んでOKを押してください。 a. Package Explorer で右クリックし、New- Project... を選択してください。 b. Android/Android Project を選択し、Next を押してください。 c. New Android Project のダイアログで、Create project from existing source(既存のソースからプロジェクトを作成)を選択してください. d. browse ボタンを押し、あなたが本エクササイズをコピーしたフォルダを選択し、その中からNotepadv1を選んでOKを押してください。 e. Project name 欄に Notepadv1、Location 欄に選択したパスが表示されることを確認してください。 f. Finish を押します。 g. 本エクササイズのプロジェクトが Eclipse の Package Explorer に開かれ準備が完了します。 h. もし AndroidManifest.xml にエラー表示が出ていたり、Android の zipファイルに関連する問題が表示された場合は、プロジェクトの上で右クリックし、ポップアップから、Android Tools- Fix Project Properties を選択してください。(プロジェクトがライブラリの場所を正しく見ていないので、この操作でそれを修復します。) Step 2 データへのアクセスと更新について このエクササイズにおいては、単にSQLiteデータベースを直接使ってデータを保存しますが、実際のアプリケーションでは正当なContentProviderを作成し、処理をカプセル化する方がずっと良いでしょう。 もし興味があれば、content provider やデータの保存/検索/表示などに関する情報をいろいろと見つけることが出来るでしょう。 DBHelper クラスを見てみてください - このクラスは、我々が作成するノートのデータを保持するとともにその更新も可能にする、SQLiteへのデータアクセスをカプセル化するために提供されています。 典型的にはContentProviderを用いることでこのクラスを実装します。そして実際、SDKには行っている完全なNotepadアプリケーションはそのようなContentProviderを実装しています。しかし、我々がこれからするように、単にSQLiteデータベースを直接利用していけない理由はありません。このクラスについて注意すべき重要なことは、それがSQLiteデータベースのデータの保存、参照、更新の詳細の面倒をみてくれるということです。全ての行を取得するメソッド、行IDに基づいて行を取得するメソッド、新しい行を作成するメソッド、既存の行を削除するメソッド、既存の行を更新するメソッドがあります。もしあなた自身のアプリケーションでSQLiteデータベースを利用する方法に関する入門を希望なら、このクラスを見てみるか、より良くは、ContentProviderの利用例として SDK の samples/ ディレクトリに入っている完全なNotepadアプリケーションを見てみてください。 Step 3 Layout と activity とについて ほとんどのActivityはそれに関連付けられたレイアウトを持っています。レイアウトはユーザに対してそのactivityの「顔」となります。今回の例では我々のレイアウトは画面全体を覆いノートの一覧を提供します。 しかし、フルスクリーンレイアウトはActivityにとっての唯一の選択肢ではありません。フローティングレイアウト(たとえばダイアログとか警告のように)が欲しいこともあるでしょうし、レイアウトを全く必要としないこともあるでしょう(使用するレイアウトを決めない場合、activityはユーザに見えなくなります)。 Open the notepad_list.xml file in res/layout and take a look at it This is a layout definition file with a default starting point in it, we have provided this as a convenience to get you going quickly. 1. All Android layout files must start with the XML header line ?xml version="1.0" encoding="utf-8"? . 2. Also, the next definition will often (but not always) be a layout definition of some kind, in this case a LinearLayout. 3. Note also that the xml namespace of Android should always be defined in the top level component or layout in the XML so that android tags can be used through the rest of the file xmlns android="http //schemas.android.com/apk/res/android" Step 4 We need to create the layout to hold our list. Add code inside of the LinearLayout tag so the whole file looks like this (you may have to hit the Source tab in order to edit the XML file) ?xml version="1.0" encoding="utf-8"? LinearLayout xmlns android="http //schemas.android.com/apk/res/android" android layout_width="wrap_content" android layout_height="wrap_content" ListView id="@id/android list" android layout_width="wrap_content" android layout_height="wrap_content"/ TextView id="@id/android empty" android layout_width="wrap_content" android layout_height="wrap_content" android text="@string/no_notes"/ /LinearLayout 1. The ListView and TextView can be thought as two alternative views, only one of which will be displayed at once. ListView will be used when there are notes to be shown, while the TextView (which has a default value of "No Notes Yet!" defined as a string resource, will be displayed if there aren t any notes to display). 2. The @ in the id strings of the ListView and TextView means that the XML parser should parse and expand the rest of the id string and use an ID resource. 3. And, the android list and android empty are IDs that are already provided for us by the Android platform, empty is used automatically when no data is provided in the list adapter. The List Adapter knows to look for these names specifically by default. Alternatively you could also choose to change the default empty view used by the List Adapter by using the setEmptyView(). More broadly, the android.R class is a set of predefined resources provided for you by the platform, while your project s R class is the set of resources your project has defined. Resources found in the android.R resource class can be used in the XML files by using the android name space prefix (as we see here). Step 5 Resources and the R class The folders under res/ in the Eclipse project are special. There is a specific structure to the folders and files under this folder. In particular, resources defined in these folders and files will have corresponding entries in the R class allowing them to be easily accessed and used from your application. Furthermore, they will be bundled and deployed as part of the application. To make a list view, we also need to define a view for each row in the list 1. Create a new file under res/layout called notes_row.xml. 2. Add the following contents (note again the xml header is used, and the first node defines the Android xml namespace) ?xml version="1.0" encoding="utf-8"? TextView id="@+id/text1" xmlns android="http //schemas.android.com/apk/res/android" android layout_width="wrap_content" android layout_height="wrap_content"/ 3. This is the view that will be used for each notes title row — it has only one text field in it. 4. In this case we create a new id called text1. The + after the @ in the id string indicates that the id should be automatically created if it does not already exist, so we are defining text1 on the fly and then using it. 5. After saving this file, open the R.java class in the project and look at it, you should see new definitions for notes_row and text1 (our new definitions) meaning we can now gain access to these from the our code. Step 6 Next, open the Notepadv1 class in the source. We are going to alter this class to become a list adapter and display our notes, and also allow us to add new notes Notepadv1 will be a subclass of Activity called a ListActivity, which has extra functionality to accommodate the kinds of things you might want to do with a list, for example displaying an arbitrary number of list items in rows on the screen, moving through the list items, and allowing them to be selected. Take a look through the existing code in Notepadv1 class. There are some constant definitions at the top, followed by a private field we will use to create numbered note titles, and some overrides of methods from the superclass. Step 7 Change the inheritance of Notepadv1 from Activity to ListActivity public class Notepadv1 extends ListActivity Note you will have to import ListActivity into the Notepadv1 class using Eclipse, ctrl-shift-O on Windows or Linux, or cmd-shift-O on the Mac (organize imports) will do this for you. Step 8 There are already three override methods defined onCreate, onCreateOptionsMenu and onOptionsItemSelected, we need to fill these out * onCreate() is called when the activity is started — it is a little like the "main" method for the activity. We use this to set up resources and state for the activity when it is running * onCreateOptionsMenu() is used to populate the menu for the activity. This is shown when the user hits the menu button, and has a list of options they can select (like "Create Note") * onOptionsItemSelected() is the other half of the menu equation, it is used to handle events generated from the menu (e.g. when the user selects the "Create Note" item). Step 9 Fill out the body of the onCreate() method. Here we will set the title for the activity (shown at the top of the screen), use the notepad_list layout we have created for the activity display contents, set up the DBHelper instance we will use to access notes data, then populate the list with the available note titles 1. call super() with the icicle parameter passed into our method 2. setContentView to R.layout.notepad_list 3. Create a new private class field called dbHelper of class DBHelper (before the onCreate method) 4. Back in the onCreate method, construct a DBHelper instance — assign to the dbHelper field (note, you must pass this into the constructor for DBHelper) 5. Finally, call a new method -fillData()- gets the data and populates it using the helper, we haven t defined it yet 6. onCreate() should now look like this @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.notepad_list); dbHelper = new DBHelper(this); fillData(); } And remember to add the DBHelper field definition (right under the noteNumber definition) private DBHelper dbHelper; Step 10 More on menus The notepad application we are constructing only scratches the surface with menus. You can also add shortcut keys for menu items, create submenus and even add menu items to other applications!. Fill out the body of the onCreateOptionsMenu() method. We are going to add just one menu item for now, "Add Item", using a string we will create in strings.xml, and defined with a constant we will create at the top of the class to identify the Add Item operation. 1. In strings.xml resource (under res/values), add a new string for menu_insert with text "Add Item" string name="menu_insert" Add Item /string , then save the file 2. Also, you need a menu position constant at the top of the Notepadv1 class (right under the KEY_BODY definition) public static final int INSERT_ID = Menu.FIRST; 3. In the onCreateOptionsMenu() method, add the menu item. Also take care of the result of the super call being returned. The whole method should now look like this @Override public boolean onCreateOptionsMenu(Menu menu) { boolean result = super.onCreateOptionsMenu(menu); menu.add(0, INSERT_ID, R.string.menu_insert); return result; } Step 11 Fill out the body of the onOptionsItemSelected() method This is going to handle our new "Add Note" menu item. When this is selected the onOptionsItemSelected() method will be called with the item.getId() set to INSERT_ID (the constant we used to identify the menu item). We can detect this, and take the appropriate actions 1. The super.onOptionsItemSelected(item) method call goes at the end of this method — we want to catch our events first! 2. Switch statement on item.getId() 3. case INSERT_ID 4. calls new method createNote() 5. break at the end of the case 6. return the result of the superclass onOptionsItemSelected() method at the end 7. The whole onOptionsItemSelect() method should now look like this @Override public boolean onOptionsItemSelected(Item item) { switch (item.getId()) { case INSERT_ID createNote(); break; } return super.onOptionsItemSelected(item); } Step 12 Add a new createNote() method In this first version of our application, createNote() is not going to be very useful. We will simply create a new note with a title assigned to it based on a counter ("Note 1", "Note 2"...) and with an empty body. At present we have no way of editing the contents of a note, so for now we will have to be content making one with some default values 1. String noteName = "Note " + noteNumber++; (Construct the name using "Note" and the counter we have defined in the class) 2. Call dbHelper.createRow() using noteName as the title and "" for the body 3. Call fillData() method again after adding (inefficient but simple) 4. The whole createNote() method should look like this private void createNote() { String noteName = "Note " + noteNumber++; dbHelper.createRow(noteName, ""); fillData(); } Step 13 List adapters Our example uses a very simple array adapter which binds an array or list of items into a ListView. More commonly in Android, List Adapters go hand in hand with ContentProviders, and this is also a very easy way to use lists. To bind a ContentProvider to a ListView you can use a android.widget.SimpleCursorAdapter to bind data from a ContentProvider into a ListView Define the fillData() method. This is fairly long This method uses ArrayAdapter, which is the simplest way of putting data into a ListView. ArrayAdapter takes either a List or an array of Strings, and binds them into a text view provided in the layout defined for the list row (this is the text1 field in our notes_row.xml layout). The method simply obtains a list of notes from the database helper, constructs a List of Strings using the title strings from each row, and then creates an ArrayAdapter out of those items and bound to use the notes_row we defined. private void fillData() { // We need a list of strings for the list items List String items = new ArrayList String (); // Get all of the rows from the database and create the item list List Row rows = dbHelper.fetchAllRows(); for (Row row rows) { items.add(row.title); } // Now create an array adapter and set it to display using our row ArrayAdapter String notes = new ArrayAdapter String (this, R.layout.notes_row, items); setListAdapter(notes); } 1. ArrayAdapter needs a List of Strings (List String ) containing the items to display 2. The data is read out of the database as rows, and the title field from each row is used to populate the list of strings 3. We specify the notes_row view we created as the receptacle for the data 4. If you get compiler errors about classes not being found, ctrl-shift-O or (cmd-shift-O on the mac) to organize imports. Note that for this exercise we use an ArrayAdapter, this is not a very scalable solution and more typically a SimpleCursorAdapter would be used with a ContentProvider or at least a Cursor returned from a query. See the sidebar on List Adapters for more information. Step 14 Run it! 1. Right click on the Notepadv1 project 2. From the popup menu, select Run As - Android Application 3. If you see a dialog come up, select Android Launcher as the way of running the application (you can also use the link near the top of the dialog to set this as your default for the workspace, this is recommended as it will stop the plugin from asking you this every time) 4. Add new notes by hitting the menu button and selecting Add Item from the menu Solution and Next Steps You can see the solution to this class in Notepadv1Solution from the zip file to compare with your own. Once you are ready, move on to Tutorial Exercise 2 to add the ability to create, edit and delete notes. Back to the Tutorial main page...
https://w.atwiki.jp/redcloud/pages/13.html
目次 目次 SDK 1.6 SDK導入 Eclipse ADT導入 Eclipse 3.4の場合 Eclipse 3.5の場合 仮想マシンAVD作成 SDK 2.0 SDK導入 Eclipse ADT導入 Eclipse 3.5の場合 add-ons ファイルの取得 仮想マシンAVD作成 ツール adb adb devices 接続デバイス確認 adb shell コンソール接続 adb install アプリインストール adb push ファイル転送 開発 Eclipse ADTでHello World SDK1.5ベース SDK1.6ベース SDK2.0ベース Map使用アプリ ステータスバー使用アプリ いじる HT-03A 道化 カスタムROM導入 読書メモ お勉強 リンク SDK 1.6 SDK導入 ダウンロードここから android-sdk-windows-1.6_r1.zip をダウンロード C \local\android-sdk-windows-1.6_r1 に解凍 PATH環境変数に、 上記解凍先フォルダ \tools を追加 Eclipse ADT導入 Eclipse 3.4の場合 eclipseを起動して、[ヘルプ]- [ソフトウェアの更新]で[使用可能なソフトウェア]タブを選択し、[サイトの追加]を押下 https //dl-ssl.google.com/android/eclipse/ を追加して、正常に追加できていることを確認 ※2009/11/3時点でバージョンは0.9.4 追加したサイトにチェックを入れ[インストール]押下 ※上記方法でうまくいかなければ。。。↓ ※実際に "No repository found containing org.apache.oro/osgi.bundle/2.0.8.v200903061218" というエラーが発生した! ダウンロードここから ADT-0.9.3.zip をダウンロード eclipseを起動して、[ヘルプ]- [ソフトウェアの更新]で[使用可能なソフトウェア]タブを選択し、[サイトの追加]を押下 [アーカイブ]を押下し、ダウンロードしてきたzipを指定、正常に追加される事を確認 追加したサイトにチェックを入れ[インストール]押下 ※アップデートの場合は下記のようなダイアログが出る ※これでもうまくいかず。。。Eclipseを3.5にするしかなさそう Eclipse 3.5の場合 eclipseを起動して、[ヘルプ]- [新規ソフトウェアのインストール]- [追加]で、https //dl-ssl.google.com/android/eclipse/ を追加 使用可能なソフトウェアの画面に戻って、[作業対象]プルダウンで追加したandroidのURLを選択。ソフトウェア表示欄にDeveloper Toolsが表示される事を確認 全てにチェックを入れて[次へ]。後はインストールをひたすら進める。(警告が出てもOKする) [ウインドウ]- [設定]- [Android]で、[SDKロケーション]にインストールしたAndroidSDKのフォルダを指定 仮想マシンAVD作成 コマンドプロンプトを開いて下記を実行 android create avd -n SDK16 -t 4 -c 128M エミュレータ起動確認 emulator @SDK16 SDK 2.0 ※SDK1.6からのアップデートを前提とした手順を記述する SDK導入 ダウンロードここから C \local\android-sdk-windows に解凍 PATH環境変数に、 上記解凍先フォルダ \tools を追加 Eclipse ADT導入 Eclipse 3.5の場合 eclipseを起動して、[ヘルプ]- [新規ソフトウェアのインストール]- [追加]で、https //dl-ssl.google.com/android/eclipse/ を追加 使用可能なソフトウェアの画面に戻って、[作業対象]プルダウンで追加したandroidのURLを選択。ソフトウェア表示欄にDeveloper Toolsが表示される事を確認 全てにチェックを入れて[次へ]。後はインストールをひたすら進める。(警告が出てもOKする) [ウインドウ]- [設定]- [Android]で、[SDKロケーション]にインストールしたAndroidSDKのフォルダを指定 add-ons ファイルの取得 eclipseを起動して、[ウインドウ]- [Android SDK and AVD Manager] [Available Packages]のリポジトリを展開し、必要な物にチェックを入れ[Install Selected]- [Accept All]にチェックを入れ[Install Accepted] 仮想マシンAVD作成 eclipseを起動して、[ウインドウ]- [Android SDK and AVD Manager] [Virtual Devices]を選択して[新規]を押下して Create new AVD画面を開く Maps APIをSDK1.5ベースで使用できる「Google APIs API Level 3」を使用する前提で。。。 名前…任意の名前を入力 ターゲット…"Google APIs(Google Inc) - API Level 3" SD Card…サイズ=任意(とりあえず128 MiB) Skin…Built-In=任意(とりあえずDefault) SDK1.6ベースの「API Level 4」を使用する前提で。。。 ターゲット…"Android 1.6 - API Level 4" SDK2.0ベースの「API Level 5」を使用する前提で。。。 ターゲット…"Android 2.0 - API Level 5" 以上を入力して[Create AVD] ツール adb adb devices 接続デバイス確認 PCに接続中のデバイス(エミュレータも含む)を表示する adb devices List of devices attached HT********** device ←実機 emulator-**** device ←エミュレータ adb shell コンソール接続 adb (-s serial number ) shell adb install アプリインストール apkファイル形式のアプリを接続中のデバイスにインストールする adb (-s serial number ) install c \hoge.apk adb push ファイル転送 SDカードにPC上のファイルを転送する adb (-s serial number ) push "c \hoge.txt" /sdcard/hoge.txt 開発 Eclipse ADTでHello World SDK1.5ベース SDK1.6ベース SDK2.0ベース Map使用アプリ TODO ステータスバー使用アプリ TODO いじる HT-03A 道化 このリンクを、Gmailからorブラウザから起動 ファイルマネージャ(AndExplorerなど)で /sdcard/download を開き(※DolphinブラウザでDLした場合はここだった)、ダウンロードしたapkファイルを選択 TODO カスタムROM導入 TODO 読書メモ Android/読書メモ お勉強 Android/お勉強 リンク TODO
https://w.atwiki.jp/interaction_android/pages/26.html
Androidのセットアップ ここでは、簡単にセットアップについて述べます (1)必要なファイル android-sdk_r17-windows.zip lpls159.exe(解凍ソフトがない場合) RapidEE_setup.exe(環境変数の設定を簡単にしたい方) (2)x64(64bit版) jdk-7u3-windows-x64.exe eclipse-jee-indigo-SR2-win32-x86_64.zip (3)x86(32bit版) jdk-7u3-windows-i586.exe eclipse-java-indigo-SR2-win32.zip 1.解凍ソフトPCに解凍ソフトが入っていない場合は「lpls159.exe」により「Lhaplus」をインストール 2.環境変数変更ソフト環境変数を簡単に変更できるように「RapidEE_setuo.exe」をクリックし、「RapidEE」をインストール 3.Java環境のセットAndroidないしEclipseはJava環境が必要なので「jdk-7u3-windows-i586.exe」によりJavaをインストールする。 項目はすべてはいないしOK 4.Cドライブの直下に「Android」フォルダを作成C \Androidとなるように 5.解凍「android-sdk_r17-windows.zip」と「eclipse-java-indigo-SR2-win32.zip」をAndroidフォルダで解凍 6.SDKのインストール「SDK Manager.exe」をクリックし、Android SDKをインストール。 すべてにチェックを入れてInstallする 7.環境パスの設定「RapidEE」を起動し、以下の分をPathの中に追加する(Add Value)。 C \Android\android-sdk-windows\platform-tools(SDKのフォルダ名によってandroid-sdk-windowsは変更すること) C \Android\android-sdk-windows\tools(SDKのフォルダ名によってandroid-sdk-windowsは変更すること) C \Program Files\Java\jdk1.7.0_03\bin C \Program Files\Java\jre7\bin 8.Eclipseの起動1~7インストール後、Eclipseの[Help]→[Install Software...]をクリック ADDをクリックし、[Android Plugin] と [https //dl-ssl.google.com/android/eclipse/]を記述しNextを押していく 再起動されればOK 9.完了これで、Androidの環境開発完了 仮に、エミュレータを作成し、実行する。ここで、エミュレータのバージョンがすべてないときは[Windows]→[Preferences]→[Android]のSDL LocationをSDKを入れたフォルダに変更 10.環境セット[Windows]→[Preferences]→[General]→[Workspace]にて文字コードを[UTF-8]に変更すること
https://w.atwiki.jp/sindroid/pages/13.html
あんどろいどなぺぇじ さて何を書こうか。 アンドロイドの構成 インストールからエミュレータ起動まで (ver 2.0用 以前のバージョンだとまた違うぽい。) ここからSDKをダウンロード →解答して適当なとこに置く →パスを通す(¥toolsまで) →プロンプトからandroidと入力するとAVDマネージャ起動 →Available Packagesからインストール ・ここで何もインストールするファイルがみつからない場合がある。 /.androidにandroidtool.cfgファイル作ってsdkman.force.http=trueと入れておくと解決するはず。 ・インストールがNothingとか出たらSDKの位置変えてみる。 (C直下とか。管理者権限だとか何か知らんけどProgram Files以下に置いてたら駄目だった。) →Virtual Devicesでデバイス作成 →そこからStartで起動 SDKリファレンス 既存バグとか チップス 他
https://w.atwiki.jp/api_programming/pages/195.html
下位ページ インテントとインテントフィルタ サービス(Service) ストレージオプション フラグメント(Fragment) プロセスとスレッド(processes and threads) リストビュー(List View) レイアウト(Layout) 入力コントロール(Controls) 設定(Setting) 通知(Notification) Content スピナーコントロールの設定レイアウトの準備 選択肢の設定string.xmlでの設定 プログラム側から値を選択する アクティビティアプリの閉じられ方で、挙動が異なる アクションバーの代わりに、ツールバーを使うアクションバーを消す ツールバーをレイアウトに追加する Activity内で、アクションバーの代わりに使う記述をする スライドメニューを実装するドロワーレイアウトを作成する ドロワービューの中身を準備するListViewで作る 別のXMLファイルで作る ドロワーのオープン・クローズを実装する バックグラウンド処理(サービス) 閉じられても動作するサービスを動かすServiceクラスの作成 Activityから、作成したサービスを動かす 加速度センサの情報を受ける 回転角の情報を受け取る回転角の解釈 画面の回転を抑制するAndroidManifest.xmlで抑制する 動的に(プラグラム内で)で抑制する インテントにオブジェクトの情報を乗っけるparcelable をインプリメントしたクラスをつくるParcelable.Creater フィールドの実装 BundleやIntentに情報を乗せる Activity側で受ける 複数の情報をリストにして表示する バイブレーションを一定時間、作動させるパーミッションの追加 Vibratorオブジェクトを生成する vibrateを実行する 通知バーにバックグラウンド起動中の表示を出す 裏返したときの方向で、記録を分ける メニューのバーを設定するメニューリソースを準備するフォルダの作成 リソースファイルの作成 設定したメニューファイルを、Activityのメニューバーに評させる メニューの選択を受け取る処理を作る チェックボックスを動作させる 設定画面を設定する/設定情報をローカルストレージに残す 記録内容をGoogleスプレッドシートに記録する 記録内容をGoogleカレンダーに記録するブラウザでURLを開く ブラウザを開くURIとして、認証ページを指定する リダイレクトを受け取る 受け取ったリダイレクトをデータに紐解く codeを送って、tokenを受け取る tokenを保存する 終了時間と開始時間から、時間の計算をする リストビューで独自レイアウトを設定する USBデバッグ リリースビルド スピナーコントロールの設定 [部分編集] レイアウトの準備 Spinner android id="@+id/planets_spinner" android layout_width="fill_parent" android layout_height="wrap_content" / 選択肢の設定 string.xmlでの設定 まずは、string.xmlに文字配列を作る string-array name="planets_array" item Mercury /item item Venus /item item Earth /item /string-array この文字配列をアダプタにして、スピナーコントロールにアダプタをするリソースのアダプタ化には、ArrayApapter.createFromResource を使用できる。simple_spinner_item はデフォルト外観を設定している。通常はこれで良し。 setDropDownViewResource(int) は選択時に一覧を表示するのに使う。なくても一応ドロップダウンは出てくるが、ちょっとしょぼい? Spinner spinner = (Spinner) findViewById(R.id.spinner); ArrayAdapter CharSequence adapter = ArrayAdapter.createFromResource(this, R.array.planets_array, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(adapter); createFromResource - ArrayAdapter | Android Developers setDropDownViewResource - ArrayAdapter | Android Developers プログラム側から値を選択する Spinner.setSelection で位置を指定する。その位置を取得するにはAdapterを使う。 使っているアダプタを取得するobjSpinner.getAdapter でアダプタを取得できる objAdapter.getPosition("...") でセレクタの位置を取得値が見つからなかったら -1 が返る objSpinner.setSelection に先程取得した位置を設定する ArrayAdapter spinnerAdapter = (ArrayAdapter) objSpinner.getAdapter(); int i = spinnerAdapter.getPosition("value"); objSpinner.setSelection(i); getAdapter - AbsSpinner | Android Developers getPosition - ArrayAdapter | Android Developers setSelection - AbsSpinner | Android Developers アクティビティ アプリの閉じられ方で、挙動が異なる onDestroyが呼ばれない限りは、Serviceを使わずとも、 ↓にある通り、ホームボタンとバックボタンでアプリケーションから離れた場合で挙動が違う。 https //kokufu.blogspot.jp/2011/03/activity.html 説明として、 ホームボタン:ホームアプリケーションが起動している バックボタン:Activityスタックからポップしている と書いてあったが、気持ち悪いのは、□ボタンを押すとあたかもまだ生きているかのように、アプリケーションリストに表示されるから。画面上に残っているが実際には onDestroy で消えている。 このあたりが、「アプリケーションをスワイプして消しても消さなくてもメモリにはそれほど影響しない」ということなんだろうか。 アクションバーの代わりに、ツールバーを使う [部分編集] 今後の拡張性から、アクションバーよりツールバーを使ったほうが良い、という記述をちょこちょこ見かけるが、Android Studioでプロジェクトを作ると、基本はアクションバーが設定されている。これをツールバーに置き換える。 アプリバーの追加 | Android Developers Toolbar | Android Developers AndroidのToolBar(新しいActionBar)メモ | Qiita アクションバーを消す res/values/styles.xmlで AppThemeのテーマを変更する style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar" ツールバーをレイアウトに追加する android.support.v7.widget.Toolbar android id="@+id/toolbar" android layout_width="match_parent" android layout_height="wrap_content" / レイアウトの@android */* ,?attr/* ,?* ,?android attr/* の違い | Qiita Activity内で、アクションバーの代わりに使う記述をする /* ToolBarの設定 */ Toolbar toolbar = (Toolbar)findViewById(R.id.toolbar); toolbar.setTitleTextColor(Color.WHITE); // 設定をしておく setSupportActionBar(toolbar); // アクションバーの代わり、という設定 これを書かないと、画面上では何も表示されない(空間だけはある) スライドメニューを実装する [部分編集] NavigationDrawer が正式名称? DrawerLayout | Android Developers ナビゲーションドロワーの作成 | Android Developers ドロワーレイアウトを作成する レイアウトxmlにて、DrawerLayout オブジェクトをレイアウトのルートビューとして指定する。 ルートの中にドロワービューとメインビューを設定する順序はメインビューを先にする高さはルートに合わせる(match_parent) 次にドロワーのビューを指定するlayout_gravityを指定する(layout_gravity:どっちにくっつけるか、どちら方向から出てくるか?)右から左に出す場合にはstart layout_heightは親ビューと同じ高さを指定する layout_widthはすべての情報が見える幅を指定する ドロワービューの中身を準備する ListViewで作る ListViewの中に android layout_gravity="..." を入れないと、スライドで入ってくる設定にならず、重ねて見えている状態になる android background="#111" 背景がないと、中途半端にすけた状態で表示される。 別のXMLファイルで作る NavigationViewで作った場合、ヘッダ部分とメニュー部分をそれぞれレイアウトとメニューで作成する app headerLayout="@layout/drawer_header" app menu="@menu/drawer" ドロワーのオープン・クローズを実装する DrawerLayout にリスナーをセットする。このリスナーは DrawerLayout.DrawerListener を実装して、使う。 Activity にアクションバーがセットされている場合は ActionBarDrawerToggle が DrawerLayout.DrawerListener を実装する。 DrawerLayout mDrawerLayout = ...; ActionBarDrawerToggle mDrawerToggle; mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.string.drawer_open, R.string.drawer_close) { public void onDrawerClosed(View view) {...} public void onDrawerOpened(View drawerView) {...} }; // Set the drawer toggle as the DrawerListener mDrawerLayout.setDrawerListener(mDrawerToggle); 【Android】スライドして表示されるメニュー | Qiita Navigation Drawer の概要 | Android 開発入門 Navigation Drawer の基本的な実装方法 | Android 開発入門 バックグラウンド処理(サービス) サービス - Android Developers Androidアプリでのバックグラウンド処理と通知機能 | Android Studio 2で始めるアプリ開発入門 - CodeZine 流れ Serviceのサブクラスを作成する AndroidManifest.xmlにサービスを登録 サブクラスで、必要なクラスをオーバーライドする。次のあたり。onCreate() onStartCommand() onDestroy() アクティビティからサービスを起動する (きちっと止まるように設計しておく) 閉じられても動作するサービスを動かす バックグラウンドで動作させるためにはServiceを用いる。 Serviceクラスの作成 Activityのように、作成・開始などのイベントで動くが、おもに3つ。 onCreate onStartCommand onDestroy Service | Android Developers Activityから、作成したサービスを動かす startServiceで起動、stopService(stopSelf)で停止。忘れずにServiceを止めないと、いつまでも動き続ける。 startService、stopServiceなどには、インテントを準備して、サービスにそれをなげる形をとっている。 startService - Context | Android Developers stopService - Context | Android Developers stopSelf - Service | Android Developers 加速度センサの情報を受ける 回転角の情報を受け取る センサーは加速度まではそのまま読み取れるが、回転角は加速度情報、地磁気情報から計算する必要がある。まず getRotationMatrix で回転行列を求め、getOrientation で回転行列を回転角に変換する(計算する) getRotationMatric - SensorManager | Android Developers getOrientation - SensorManager | Android Developers 引数に取った2つの配列には、傾斜行列、回転行列(の情報)が計算されて入ってくる。情報が不要ならnullでよい。 回転角の解釈 正位置として Zは天を指す Yは磁北を指す Xは Y,Z の外積を指す 画面の回転を抑制する AndroidManifest.xmlで抑制する 回転させないActivityに android screenOrientation="portrait" を追加すると、縦向き固定になる activity | Android Developers 動的に(プラグラム内で)で抑制する Activity内で、setRequestedOrientation を呼び出す setRequestedOrientation - Activity | Android Developers screenOrientation - ActivityInfo | Android Developers インテントにオブジェクトの情報を乗っける bundleで多くの情報をわたすような方法として、putParcelableArrayList くらいしか見当たらないので、これを使う。そのためには、Parcelable をimplements したようなクラスを作る必要がある。 Bundle | Android Developers parcelable をインプリメントしたクラスをつくる Parcelable実装にはParcelable.Createorというstatic fieldが必要。そのフィールドの初期化にて、Parcelに保存したデータを復元するためのコンストラクタを呼ぶ。 Parcelable | Android Developers Parcelable.Creater フィールドの実装 Parcelable.Creater | Android Developers createFromParcel(Parcel source)Parcelable.writeToParcel() で書き出されたParcelデータをインスタンス化する → コンストラクタを作っておく newArray(int size)ParcelableクラスのArrayを作る BundleやIntentに情報を乗せる IntentならputParcelableArrayListExtra、BundleならputParcelableArrayList で情報を登録 putParcelableArrayListExtra - Intent | Android Developers getParcelableArrayList - Bundle | Android Developers Activity側で受ける IntentならgetParcelableで受けられる。受けたときにすでにParcelableをimplementしたオブジェクトで受けられる。 getParcelableArrayListExtra - Intent | Android Developers getParcelableArrayList - Bundle | Android Developers 複数の情報をリストにして表示する [https //www54.atwiki.jp/api_programming/pages/202.html] バイブレーションを一定時間、作動させる Vibratorインスタンスからvibrate()を実行する。バイブレーションの実施にはAndroidManifest.xmlにパーミッションの追加が必要。 パーミッションの追加 マニフェストにパーミッションを追加する - パーミッションの宣言 | Android Developers Vibratorオブジェクトを生成する getSystemServiceでVibratorオブジェクトを生成する Vibrator vibrator = (Vibrator) getSystemService(VIBRATOR_SERVICE); getSystemService - Context | Android Developers Vibrator | Android Developers vibrateを実行する 幾つかパターンはあるが、かんたんなところで、これ。 vibrator.vibrate(500); vibrate - Vibrator | Android Developers 通知バーにバックグラウンド起動中の表示を出す 裏返したときの方向で、記録を分ける メニューのバーを設定する メニューリソースを準備し、表示させる。そのうえで、メニューのタップ動作に対する反応を記述する メニュー | Android Developers メニューリソースを準備する フォルダの作成 デフォルトではメニュー用のフォルダが無い(かもしれない)ので、res/menuを追加し、ここに入れておく。 resフォルダ右クリック [New]>[Android resource directory]を選択 ダイアログで、「Resource type 」から「menu」を選択し、OK リソースファイルの作成 menuフォルダを右クリック [New]>[Menu resource file] ファイル名を入力し、OK ファイル内に menu item / item / /menu を記述(実際はidやタイトルを設定する必要あり) Menu Resource | Android Developers 設定したメニューファイルを、Activityのメニューバーに評させる onCreateOptionMenuをオーバーライドして、この中でリソースの指定などを行う。XMLのメニューを実際?のメニューオブジェクトに変換するのに、inflatorを使用できる。 @Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); //(1) inflater.inflate(R.menu.menu_options_menu_list, menu); //(2) return super.onCreateOptionsMenu(menu); //(3) } onCreateOptionMenu - Activity | Android Developers メニューの選択を受け取る処理を作る オプションメニューを作っていれば、その受取はonOptionsItemSelectedをオーバーライドして処理できる。 @Override public boolean onOptionsItemSelected(MenuItem item) { return super.onOptionsItemSelected(item); } このとき、itemにクリックされた情報が入っているので、これを紐解いて、どのメニューがクリックされたか判断し、switchなどで処理する。 int itemId = item.getItemId(); Android 3.0(APIレベル11)以降では メニューリソースXMLのitemに、android onClick を記述しておくことで、動作を定義させることもできる。 チェックボックスを動作させる Android/入力コントロール(Controls) 設定画面を設定する/設定情報をローカルストレージに残す Android/設定 記録内容をGoogleスプレッドシートに記録する http //qiita.com/konnobu/items/8bec3d5a45235fc88a08 記録内容をGoogleカレンダーに記録する 多分、クライアント用のライブラリが作られていて、簡単に認証処理をしたり、データを取得したりできるようになっていると思われるが、別サイトでも転用が聞くように、地道な方法を取ってみる。というか、専用のライブラリの使い方をよくわかっていない。 流れは OAuth2.0で認証Google API にプロジェクトと登録(キーの発行) 認証コードを発行 受け取り コードを access token と交換 access token も使って、リクエスト送信 こまごまと引っかかった場所が多数。 AndroidManifest.xmlにパーミッションの設定が必要 ブラウザでURLを開く Android/インテントとインテントフィルタ ブラウザを開くURIとして、認証ページを指定する GoogleのOAuth2認証 OAuth2認証 | Android Developers Step 1 Send a request to Google's OAuth 2.0 server | Google Identify Platform リダイレクトを受け取る 大概の(google 以外でも)場合は、認証後に指定したリダイレクト先に飛ばしてくれる。そのスキーム名に応じて、Android側でどのアプリで開くのかを考えてくれる。Android に「このスキームがきたら、俺のアプリで開いて」と指示するためには、AndroidManifest.xml に記述する必要がある。 scheme // host port / path intent-filter内で、action, category, data を指定する。上記のリダイレクト先に対応する内容を書くのは data で、scheme は data android scheme="com.example.testproject" / のようになる。 Intent の 定数として ACTION_VIEW などが定義されているが、実体は文字列で、それが android.intent.action.VIEW などになる(ので、どれを設定するかはIntent を参照)。ブラウザでどんなスキームがきたらヨソになげるのか、どんな action として投げるのか、説明されている場所がわからないが、ひとまず action ACTION_VIEW category CATEGORY_BROWSABLR scheme ここは各自で で開けた。redirect_uri で scheme //~ が指定できない( /だけ)なので、hostは存在せず、pathだけ。 インテント解決 - インテントとインテント フィルタ | Android Developers Intent - Android Developers 受け取ったリダイレクトをデータに紐解く 一旦受け取れれば、中身は getIntent() を経由して、中身を見られる(Intent.getAction(), Intent.getCategories() など)。OAuth では、path のなかに code を入れて返してくるので、Dataのなかを探せばある Intent intent = getIntent(); String data = intent.getDataString(); とすると、googleの認証で指定した redirect_uri のあとに code がくっついて返ってきている。以下、サンプル com.example.####.#### /oauth2callback?code=4/8abcdefg# 上記の場合、oauth2callback を uri.getPath() で、4/8abcdefg# を getQueryParameter("code") で受け取れる。 getIntent - Activity | Android Developers getData - Intent | Android Developers getQueryParameter - Uri | Android Developers codeを送って、tokenを受け取る コードと必要情報を POST することで、access token との交換をする。この処理は、UIスレッドだとエラーになるので、AsyncTaskで実行する必要がある。 また、交換がうまく行かなかったときは、HttpURLConnection の getInputStream ではなく、 getErrorStream に情報が流れるため、プログラムの確認作業では注意。(この辺をよくわかっていなくて、エラー原因を探すのに苦労した。) redirect_uri はスキームもパスもコード発行依頼時と同じものを使う。 Android/プロセスとスレッド(processes and threads) Async Task | Android Developers tokenを保存する プレファレンスへの保存 終了時間と開始時間から、時間の計算をする リストビューで独自レイアウトを設定する https //www54.atwiki.jp/api_programming/editx/202.html USBデバッグ http //www.aiseesoft.jp/tutorials/android-debug-mode.html リリースビルド http //androidstudio.hatenablog.com/entry/2014/07/26/154043
https://w.atwiki.jp/android/pages/48.html
2008/04/15 Android Developer Challenge締め切り。 2008/03/25 「Android」搭載端末、早くも2008年秋には登場か?--グーグル幹部が発言 2008/03/23 ドコモ携帯、基本ソフトの設計簡素化へ DoCoMoでAndroid採用が決定? 2008/02/18 WCMフォーラムの会員一覧が更新。OHA企業が参加 WILLCOMコアモジュールフォーラムの会員にOHA参加企業のリビングイメージという会社が参入した模様。WILLCOMからAndroid携帯が出る可能性が出てきた。 2008/02/12 Android SDKアップデート 結構変わってます。今までのアプリを新しいSDK(m5-rc14)で動かすには再コンパイル(?)が必要です。 2008/02/11 Mobile World CongressにてAndroidの実機がぞくぞく出展された 【MWC2008】「Android」搭載プロトタイプ、半導体メーカーがこぞって出展 Android実機を披露した主な企業米フリースケール・セミコンダクタ NECエレクトロニクス 米クアルコム ルネサス テクノロジ 米テキサス・インスツルメンツ 2008/02/04 ハドソン、ゲームソフトをグーグル携帯に提供 ゲーム開発のハドソンは米グーグルが提供予定の携帯電話ソフトウエア群「アンドロイド」向けに、ゲームソフトなどの娯楽コンテンツ(情報の内容)を開発する。グーグルの携帯電話はNTTドコモなどが導入を検討しているが、国内コンテンツ大手の参入が明らかになったのは初めて。 2008/01/28 Deadline Extension for the Android Developer Challenge コンテストの締め切り延長と詳細日程の発表される (この時点から)数週間以内にUIとAPIが強化されたSDKをリリースするとのこと。 2008/04/14 Deadline to submit applications for judging 応募締め切り 2008/05/05 Announcement of the 50 first round winners, who will be eligible for the final round 1回戦の上位50人を発表 2008/06/30 Deadline for the 50 winners of the first round to submit for the final round 最終戦の締め切り 2008/07/21 Announcement of the grand prize winner and runner-up 優勝者および優秀者の発表 2008/01/24 ドコモとグーグル、iモード端末でグーグルのサービス利用可能に 「Androidプラットフォームに関しても両社で協力し、ドコモでの商用化を含む検討が進められる」と発表 2008/01/14 Google Android対応の初アプリケーション登場 初ってことはないと思うけど、OHA参加以外の企業で実機で自社アプリを動かしたのは初? 2007/12/28 ビルド済みバイナリでもAndroid Zaurusが可能に 2007/12/25 ドコモ、グーグルと提携・ネット検索メールなど、新サービス開発 この時点ではAndroidとの係わりは不明。 2007/12/15 Android SDKアップデート(英語) 2007/12/6 WILLCOMコアモジュールフォーラム、AndroidでW-SIMの通話デモ Androidをザウルスに載せた(英語) 2007/11/27 WILLCOMコアモジュールフォーラム、Androidの動作を確認 2007/11/17 Androidでスーパーマリオ(ファミコン/NES)が動いた。 2007/11/12 GoogleのAndroidプラットフォーム SDK公開 Google、Android向けアプリ開発コンテストを主催、賞金1000万ドル コンテストまとめ 2007/11/5 Googleほか34社、オープン携帯プラットフォーム「Android」を発表
https://w.atwiki.jp/android_api/pages/17.html
Androidアプリは「アクティビティ」、「ブロードキャストレシーバー」、「サービス」、「コンテンツプロバイダ」の4つの構成要素から成り立ちます。 リソースクラスです。標準的なアンドロイドアプリケーションに使用されます。このパッケージにはアンドロイドアプリケーションを使う際の定義がされています。サードパーティの開発者が使うことのできるたくさんのアップリケーションがあります。リソースの詳細についてはリソースとアセットをご覧ください。
https://w.atwiki.jp/pjkyt/pages/15.html
日本語 What s this? As far as I know, Android SDK has no offering of standard FileDialog as it exists for Java SE. I thought it might help to make something simple available. It s just a toy code. Feel free to do anything with it. Download What it does It works in four modes 1. Select file 2. Create file 3. Select directory 4. Create directory In mode 1 and 3, the file dialog have the user select existing file / directory. User can navigate through the file system up and down and tap on the desired the file (Figure 1). In case of selecting directory, user can press Here to specify the current directory. In mode 2 and 4, the file dialog have the user enter the new file / directory name that he wishes to create. User can navigate through the file system up and down and tap Here to designate where the file should be created (Figure 2). Then a text box dialog appears and asks for the new file / directory name (Figure 3). In case a file is selected, the text box is brought up with the selected file name filled in. How it works Here s an example code you ll find in the download package. The code inside onCreate() corresponds to the four mode explained above. The first argument is the initial directory. The second and third controls the mode. And the fourth and fifth passes the Context and FileDialogue.Listener. FileDialogue.Listener must be implemented to receive the result from FileDialogue. fd.showDialogue() launches the dialog box. When user has made selection, onSelected() is invoked with the directory and file name as an argument (filename will be "" when ). Else when user has pressed the "back" button, onCanceled() is invoked. That s it! public class FdExample extends Activity implements FileDialogue.Listener { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); // (1) Select file, starting direcotry is /sdcard/ FileDialogue fd = new FileDialogue(null, FileDialogue.FILE, FileDialogue.SELECT, this, this); // (2) Create file, starting direcotry is /sdcard/, user will be requested to enter filename // FileDialogue fd = new FileDialogue("/sdcard/picture/", FileDialogue.FILE, FileDialogue.CREATE, this, this); // (3) Select directory, starting direcotry is /sdcard // FileDialogue fd = new FileDialogue(null, FileDialogue.DIRECTORY, FileDialogue.SELECT, this, this); // (4) Create directory, starting direcotry is /sdcard/, user will be requested to enter direcotry name // FileDialogue fd = new FileDialogue(null, FileDialogue.DIRECTORY, FileDialogue.CREATE, this, this); fd.showDialogue(); } public void onSelected(String directory, String filename) { // filename will be "" when target is the FileDialogue.DIRECOTRY Log.v("FdExample", "Directory = " + directory + ", File = " + filename); } public void onCanceled() { // this is when "back" button is pressed Log.v("FdExample", "Canceled"); } } Is this as good as it gets? Actually, I had never liked the file dialog in general. It is rather tiring to use it. As it is launched, I must resolve where I am now and plan how I should travel to the objective location. It s a lot of screen interpretation, a lot of structural memory challenge, and not even a hint of joy. It it one UI scheme that abuses the weak parts of the human capability. So we have some idea going. We are thinking we can create a better alternative that can take advantage of parallel processing of visual image and geometric / chromatic memory -- human is much better at those. It will be quick to get desired location, much less stressful to use, and hopefully fun. I hope we can implement the idea quickly and make available through this wiki soon. アルバイトはじめましたd(´∀`*)グッ♪ http //www.e29.mobi/ -- (わかりません) 2012-01-05 04 12 48 名前 コメント すべてのコメントを見る
https://w.atwiki.jp/mywiki2010/pages/14.html
USBブート可能なx86マシンでAndroidを動作させる。 参考サイト一覧 「Android」をx86パソコンで動かそう ITpro 話題の携帯向けOS「Android」をx86パソコンで動かしてみよう (2009/02/27) ブログなど NWLab.com USB起動可能なAndoroid OSでPCからAndroidを起動してみました(2009/04/13) 即席USBブート環境構築(Windows編) ダウンロード可能なイメージファイルでお手軽にAndroidを動作させる。 (更新 2010/02/09) (1) 必要なものを用意 WindowsがインストールされたPC USBブート可能なPC(WindowsPCと同じでも良い) USBメモリ1GBもあれば十分。 FAT32でフォーマットしておく。 不慮の事故でデータが消えても困らないよう、大事なデータは事前にバックアップ。 (2) Androidのブート・イメージ入手 「USBブート・イメージ入手先」からファイルをダウンロードする。 (3) ブート・イメージの書き込み 書き込みソフトを使ってブート・イメージをUSBメモリに書き込む。 ソフト一覧 DDforWindowsWindowsXP, WindowsVistaで使用可。他Windowsでは未検証。 本ソフトでUSBから読み込んだディスクイメージはLinuxのddコマンドでそのまま使用可能。 (4) Android起動 Andoridを動かすPCでUSBブート可能になるようBIOSを設定するEeePC1000HEでは、PC起動時にESCキーを連打することでブート・ドライブを選択可能。 電源の入っていないPCのUSBポートにUSBメモリを差し込む 電源を入れるとAndroidが立ち上がる起動中にもUSBアクセスを行っているので、USBメモリは抜かないよう注意。 設定を変更した場合(表示言語など)は変更内容がUSBメモリに書き込まれ、次回起動時にも反映される。